package algorithm7.util;


public class Compare {

    public static void main(String[] args) {
        int[] res = getRandomArr(10, 10);
        for (int i = 0; i < res.length; i++) {
            System.out.println("res[" + i + "] = " + res[i]);
        }
    }

    /**
     * 获取一个随机数组，长度 [0, maxLen)，值 [0, maxVal)
     * @param maxLen 最大长度
     * @param maxVal 最大值
     * @return arr
     */
    public static int[] getRandomArr (int maxLen, int maxVal) {
        int len = (int) (Math.random() * maxLen);
        int[] arr = new int[len];
        for (int i = 0; i < len; i++) {
            arr[i] = (int) (Math.random() * maxVal);
        }
        return arr;
    }
}
